import http from "./http";
// 登录
function logins(params) {
  return http.post("/login", params);
}
// 用户
function menus() {
  return http.get("/menus");
}
// 分类权限
function menu(params) {
  return http.put(`/users/${params.id}/role`,{...params});
}

// 用户列表
function users(params) {
  return http.get("/users", { params });
}
// 添加用户
function addUser(params) {
  return http.post("/users", params);
}
// 删除用户
function deleteUser(id) {
  return http.delete("/users/" + id);
}
// 编辑用户
function editok(params) {
  return http.put(`/users/${params.id}`, params);
}
// 切换状态
function status(uId, type) {
  return http.put("/users/" + uId + "/state/" + type);
}
//获取角色列表
function gteroled() {
  return http.get("/roles");
}
// 添加角色
function addrole(params) {
  return http.post("/roles", params);
}
// 删除角色
function deleterole(id) {
  return http.delete("/roles/" + id);
}
// 编辑角色
function editrole(params) {
  return http.put(`/roles/${params.id}`, params);
}
// 权限
function list() {
  return http.get(`/rights/tree`);
}
// 添加权限
function addroles({ roleId, rids }) {
  return http.post(`roles/${roleId}/rights`, { rids });
}
// 删除权限
function deleteroles({ roleId, rightId }) {
  return http.delete(`roles/${roleId}/rights/${rightId}`);
}
// 权限列表
function rights() {
  return http.get(`/rights/list`);
}
// 订单列表
function orders(params) {
  return http.get("/orders", { params });
}
// 物流
function logistics(id) {
  return http.get("/kuaidi/" + id);
}
// 商品列表数据
function goods(params) {
  return http.get("/goods", { params });
}
// 商品分类
function categorys(params) {
  return http.get("/categories", { params });
}
// 商品分类删除
function delcate(id) {
  return http.delete(`/categories/${id}`);
}
// 添加分类
function addcategory(params) {
  return http.post(`/categories`, params);
}
// 编辑分类
function editcategory(params) {
  return http.put(`/categories/${params.id}`, { cat_name: params.cat_name });
}
// 参数列表
function cates(params){
return http.get(`categories/${params.id}/attributes`,{params:{sel:params.sel}})
}
// 添加动态参数
function addcate(params) {
  let {attr_name,attr_sel}=params;
  return http.post(`/categories/${params.id}/attributes`, {attr_name,attr_sel});
}
// 删除参数
function del(params) {
  return http.delete(`categories/${params.id}/attributes/${params.attrid}`);
}
// 添加tag标签
function addtags(params) {
  return http.put(`categories/${params.id}/attributes/${params.attrId}`,{attr_name:params.attr_name,attr_sel:params.attr_sel})
};
// 删除列表删除
function delslist(id){
return http.delete("goods/"+id)
}
// 商品列表添加
function addlists(params){
return http.post("/goods",params)
}
// 折线图
function xian(){
  return http.get("reports/type/1")
}
//上传图片
function uploadurl(params) {
  return http.post("/upload", params);
}
export {
  uploadurl,
  xian,//折线图
  addlists,
  delslist,//删除列表删除
  addtags,//添加tag标签
  del,//删除参数
  addcate,//动态参数
  cates,//参数列表
  menu,
  addcategory,//添加分类
  editcategory, //编辑分类
  delcate, //删除分类
  categorys, //商品分类
  goods, //商品列表
  logistics,
  orders,
  rights,
  deleteroles,
  addroles,
  list,
  logins,
  menus,
  users,
  addUser,
  deleteUser,
  editok,
  status,
  gteroled,
  addrole,
  deleterole,
  editrole,
};
